<?php
// $Id: template.php,v 1.1 2010/03/18 13:42:12 zyxware Exp $
?>
<?php
/**
 * Return a themed set of links.
 *
 * @param $links
 *   A keyed array of links to be themed.
 * @param $attributes
 *   A keyed array of attributes
 * @return
 *   A string containing an unordered list of links.
 */
function chocotheme_links($links, $attributes = array('class' => 'links')) {
  global $language;
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
          && (empty($link['language']) || $link['language']->language == $language->language)) {
        $class .= ' active';
        $active=' active';
      }
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .='<a href="'. url($link['href']) .'" class="'. $active .'" ><span>'. $link['title'] .'</span></a>';
        //$output .= l($title, $link['href'], $link);
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }

  return $output;
}

/**
 * Override of the Search Box for d6
 * first, select the form ID
 */
function chocotheme_theme() {
    return array(
    // The form ID.
    'search_block_form' => array(
      // Forms always take the form argument.
      'arguments' => array('form' => NULL),
    ),
  );
}
/**
  * Theme override for search form.
  * Paste this in the template.php file of your theme
  * more infos : lullabot.com/articles/modifying-forms-5-and-6
  * Here is where you can modify the selected form
  */

function chocotheme_search_block_form($form) {
    $form['search_block_form'] ['#title']=NULL;
    $form['search_block_form']['#attributes']=array("class" => "field");
    $form['submit']['#value']=NULL;
    $form['submit']['#attributes']= array("class" => "button");
    $output .= drupal_render($form);
    return $output;
}

function chocotheme_comment_submitted($comment) {
    return t('<p class="author">!username</p><p class="comment-meta" >@date at about @time.</p>', array(
    '!username' => theme('username', $comment),
    '@date' => format_date($comment->timestamp, 'custom', 'd M Y'),
    '@time' => format_date($comment->timestamp, 'custom', 'H:i')
    ));
}